	<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="/resource/UserPwoer.tld" prefix="p"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	pageContext.setAttribute("fnId", request.getAttribute("fnId"));
	pageContext.setAttribute("userPwoer", request.getSession().getAttribute("userPwoer"));
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
</head>
<body class="gray-bg">
	<nav class="huiNav">
		<i class="fa fa-home"></i> 首页 <span>&gt;</span>客户信息<span>&gt;</span>会员管理
		<a class="btn btn-info  btn-sm pull-right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="fa fa-refresh"></i></a>
	</nav>

	<div class="ibox-content">
	<!-- 搜索框部分start -->
	<p:btn value="serch">
		<form class="form-inline" id="serchform">
			<div class="form-group mr-20">
				<label for="exampleInputName2">会员姓名</label>
				<input name="name" type="text" class="form-control">
			</div>
			<div class="form-group mr-20">
				<label for="exampleInputName2">会员电话</label>
				<input name="tel" type="text" class="form-control">
			</div>
			<button  onclick="myGrid.serchData()" type="button" class="btn btn-info btn-sm"><i class="fa fa-search " ></i> 搜索</button>
			<button  type="reset" class="btn btn-info btn-sm"><i class="fa fa-refresh " ></i> 重置</button>
		</form>
		</p:btn>
	<!-- 搜索框部分en -->
		<div class="option-bar" >
		<button onclick="openAdd()" type="button" style="background: #000;"
					class="btn btn-success btn-sm">
					<i class="fa fa-plus"></i> 新增黑名单用户
				</button>
		</div>
		<table id="mgrid" >
			<thead>
				<tr>
					<th data-checkbox="true"  ></th>
					<th data-formatter="MGrid.indexfn" data-align="center"  data-width="30px" >序号</th>
					<th data-field="name" >用户姓名</th>
					<th data-field="tel" >电话</th>
					<th data-field="photo" data-formatter="MGrid.getImage" >头像</th>
					<th data-field="registerTime" >注册时间</th>
					<th data-field="accountStatus"  data-formatter="buidStatus">账号状态</th>
					<th data-field="registerTime" data-formatter="MGrid.getTime" data-sortable="true" >注册时间</th>
					<th data-align="center"  data-width="150px" data-field="id" data-formatter="buidOperate">操作</th>
				</tr>
			</thead>
		</table>
	</div>
	
	<script type="text/javascript">
	var myGrid;
		$(function(){
			var delUrl="";
			<p:btn value="dels">
				delUrl="${path}/admin/customer/del";
			</p:btn>
			 myGrid=MGrid.initGrid({
				 url:"${path}/admin/customer/showList",
				 delUrl:delUrl
			 });
		});
		function buidStatus(value, row, index){
			if(value=="activate"){
				return "<span class='label label-success' >正常</span>";
			}else if(value=="locked"){
				return "<span class='label label-warning' >已锁定</span>";
			}
		}
		
		
		function buidOperate(value, row, index){
			var html='';
			<p:btn value="lock">
			if(row.accountStatus=="activate"){
				html+='<button class="btn btn-default btn-sm mr-5" onClick="resetPass('+value+',1)" title="锁定"><i class="fa fa-lock"></i></buttoun>';
			}else if(row.accountStatus=="locked"){
				html+='<button class="btn btn-default btn-sm mr-5" onClick="resetPass('+value+',2)" title="解锁"><i class="fa fa-unlock"></i></buttoun>';
			}
			</p:btn>
			html+='<button class="btn btn-default btn-sm mr-5" onClick="openEdit('+value+')"  title="编辑"><i class="fa fa-edit"></i></buttoun>'
			return html; 
		}
		
		//打开编辑界面
		function openEdit(id) {
			layer.open({
				type : 2,
				title : "编辑黑名单",
				area : [ MUI.SIZE_L, '400px' ],
				maxmin : true,
				content : [ '${path}/admin/userEditForm?id=' + id]
			});
		}
		
		//打开添加界面
		function openAdd() {
			layer.open({
				type : 2,
				title : "添加黑名单",
				area : [ MUI.SIZE_L, '400px' ],
				content : [ '${path}/admin/userEditForm']
			}); 
		}
		
		
		//重置密码
		<p:btn value="lock">
		function resetPass(id,type){
			var msg="";
			if(type==1){
				msg="确定要锁定该账户吗";
			}else if(type==2){
				msg="确定要解冻吗";
			}
			
			layer.msg(msg, {
				  time: 0 ,
				  icon:3,
				  btn: ['确定', '取消'],
				  yes: function(index){
				     layer.close(index);
				    //*把密码设置为123
					$.AjaxProxy(
							{a : false,
							 c : false,
							 p:{id:id,kind:type}}).invoke("${path}/admin/customer/chengUserStatu",function(loj){
						if(loj.attr("result").status=='ok'){
							layer.msg("操作成功",{icon:1});
							myGrid.serchData();
						}
					});
					
				  }
				});
			
			
		}
		</p:btn>
	</script>
</body>
</html>
